package com.lanzhou.yuanfen.controller;

import com.lanzhou.yuanfen.response.ServerResponseResult;
import com.lanzhou.yuanfen.sys.entity.User;
import com.lanzhou.yuanfen.sys.service.IUserService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @ClassName: {@link RingController}
 * @Description: RingController
 * @author: Lanzhou
 * @date: 2020/7/25 23:43
 * @QQ: 1627518680
 * @Copyright:2020 All rights reserved.
 */
@RestController
@RequestMapping("/ring/")
public class RingController {

    @Resource
    private IUserService userService;

    /**
     * 游客获取发布者信息
     *
     * @param mem 会员ID
     * @return 用户信息
     */
    @PostMapping("members")
    public ServerResponseResult members(@RequestParam("mem") String mem) {
        String[] mems = mem.split("mem");
        if (mems.length == 2) {
            User user = userService.getById(mems[1]);
            if (user == null) {
                return ServerResponseResult.fail("用户不合法请, 请不要违规操作");
            }
            user.setPassword(null);
            return ServerResponseResult.success(user);
        } else {
            return ServerResponseResult.fail("用户不合法请, 请不要违规操作");
        }
    }


}

